package Ep06_BinaryTree._0202;

import Ep06_BinaryTree.TreeNode;

import java.util.List;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/5/4 14:03
 * 说明：
 */

public class Mine {
    public int countNodes(TreeNode root) {
        if (root == null) return 0;
        int count = 0;
        count = preOrder(root, count);
        return count;
    }

    public int preOrder(TreeNode root, int count){
        if (root == null) return count;
        count++;
        count = preOrder(root.left, count);
        count = preOrder(root.right, count);
        return count;
    }
}
